import { createSlice } from '@reduxjs/toolkit';

// export const getUserInfoAsync = createAsyncThunk('user/getUserInfo', async (userId, thunkAPI) => {
//   const { data } = await window.userService.getUserInfo();
//   return data;
// });
const userSlice = createSlice({
  name: 'user',
  initialState: {
    // 用户信息
    userInfo: {},
    // 菜单信息
    menu: {},
  },
  reducers: {
    updateUser(state, action) {
      /* 修改用户信息 */
      if (action.payload) {
        state.userInfo = action.payload;
      }
    },
  },
  // extraReducers: (builder) => {
  //   builder.addCase(getUserInfoAsync.fulfilled, (state, { payload }) => {
  //     if (payload) {
  //       state.userInfo = payload.userInfo;
  //       state.menu = payload.menuList;
  //     }
  //   });
  // },
});
export const { updateUser } = userSlice.actions;
export default userSlice.reducer;
